package tbalert.web.dao.impl;

import java.util.List;

import org.hibernate.HibernateException;

import tbalert.hibernate3.Finder;
import tbalert.hibernate3.HibernateBaseDao;
import tbalert.page.Pagination;
import tbalert.web.dao.RoleDao;
import tbalert.web.entity.Role;

public class RoleDaoImpl extends HibernateBaseDao<Role, Integer> implements RoleDao {

	public Role deleteById(Integer id) {
		Role entity = super.get(id);
		if (entity != null) {
			getSession().delete(entity);
		}
		return entity;
	}

	@Override
	public Pagination find(Finder finder, int pageNo, int pageSize) {
		return super.find(finder, pageNo, pageSize);
	}

	@Override
	public Role findById(Integer id) {
		return get(id);
	}

	@SuppressWarnings("unchecked")
	public List<Role> getAll() {
		return find("from Role");
	}

	@Override
	public Role save(Role bean) throws HibernateException {
		getSession().save(bean);
		return bean;
	}

	@Override
	protected Class<Role> getEntityClass() {
		return Role.class;
	}
}
